/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tools.cryptage;

import java.math.BigInteger;
import java.util.Calendar;

/**
 *
 * @author ADRIEN
 */
public class ImplOTPTime implements IOTPTime{
    
    public Integer nextOtp(Integer first_password)
    {
       ICryptage engine = new FacadeSha1();
       long time = (long)(Calendar.getInstance().getTime().getTime() / 120000);
       String chaine = engine.cryptage(String.valueOf(time),"") + "_" + engine.cryptage(first_password.toString(),"");
       byte[] nombre = engine.cryptage(chaine,"").getBytes();
       String szResultat = new BigInteger(nombre).toString().substring(2,10);
       return Integer.parseInt(szResultat);
    }
}
